
<?php echo $header; ?>
<style>
	.hidden_oject{
		display:none;
	}
</style>
<div id="content">
  <div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
  </div>
  <?php if ($error_warning) { ?>
  <div class="warning"><?php echo $error_warning; ?></div>
  <?php } ?>
  <div class="box">
  <div class="heading">
    <h1><img src="view/image/product.png" alt="" /><?php echo $heading_title; ?></h1>
    <div class="buttons"><a onclick="$('#form').submit();" class="button"><span><?php echo $button_save; ?></span></a><a onclick="location = '<?php echo $cancel; ?>';" class="button"><span><?php echo $button_cancel; ?></span></a></div>
  </div>
  <div class="content">
    <div id="tabs" class="htabs"><a href="#tab-general"><?php echo $tab_general; ?></a><a href="#tab-data"><?php echo $tab_data; ?></a></div>
    <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
      <div id="tab-general">
        <div id="languages" class="htabs">
          <?php foreach ($languages as $language) { ?>
          <a href="#language<?php echo $language['language_id']; ?>"><img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" /> <?php echo $language['name']; ?></a>
		  <?php } ?>
        </div>
        <?php foreach ($languages as $language) { ?>
        <div id="language<?php echo $language['language_id']; ?>">
          <table class="form">
            <tr>
              <td><span class="required">*</span> <?php echo $entry_name; ?></td>
              <td><input name="download_extra_description[<?php echo $language['language_id']; ?>][name]" size="100" value="<?php echo isset($download_extra_description[$language['language_id']]) ? $download_extra_description[$language['language_id']]['name'] : ''; ?>" />
                <?php if (isset($error_name[$language['language_id']])) { ?>
                <span class="error"><?php echo $error_name[$language['language_id']]; ?></span>
                <?php } ?></td>
            </tr>
			<tr>
              <td><?php echo $entry_short_description; ?></td>
              <td><textarea name="download_extra_description[<?php echo $language['language_id']; ?>][short_description]" cols="40" rows="5"><?php echo isset($download_extra_description[$language['language_id']]) ? $download_extra_description[$language['language_id']]['short_description'] : ''; ?></textarea></td>
            </tr>
     
            <tr>
              <td><?php echo $entry_description; ?></td>
              <td><textarea name="download_extra_description[<?php echo $language['language_id']; ?>][description]" id="description<?php echo $language['language_id']; ?>"><?php echo isset($download_extra_description[$language['language_id']]) ? $download_extra_description[$language['language_id']]['description'] : ''; ?></textarea></td>
            </tr>
          </table>
        </div>
		<?php } ?>
      </div>
      <div id="tab-data">
        <table class="form">
		  <tr style="height:180px;">
            <td><span class="required">*</span> <?php echo $entry_video; ?></td>		
            <td>
				<input type="hidden" name="file_name" value="<?php echo $file_name; ?>" id="file_name" />
				<a class="button" id="download_file"><span id="txt_upload"><?php echo $text_upload; ?></span></a>
				<span id="txt_file_name"><?php echo $file_name; ?></span><br><br>
				<a class="button" onclick="delete_file('<?php echo $download_extra_id;?>');"><span ><?php echo $text_delete; ?></span></a><br>
				 <?php if (isset($error_file_name)) { ?>
                <span class="error"><?php echo $error_file_name; ?></span>
                <?php } ?>
			</td>
          </tr>
          <tr>
            <td><?php echo $entry_keyword; ?></td>
            <td><input type="text" name="keyword" value="<?php echo $keyword; ?>" /></td>
          </tr>
		  <tr>
              <td><?php echo $entry_image; ?></td>
              <td><div class="image"><img src="<?php echo $thumb; ?>" alt="" id="thumb" /><br />
                  <input type="hidden" name="image" value="<?php echo $image; ?>" id="image" />
                  <a onclick="image_upload('image', 'thumb');"><?php echo $text_browse; ?></a>&nbsp;&nbsp;|&nbsp;&nbsp;<a onclick="$('#thumb').attr('src', '<?php echo $no_image; ?>'); $('#image').attr('value', '');"><?php echo $text_clear; ?></a></div></td>
            </tr>
		  <tr>
            <td><?php echo $entry_status; ?></td>
            <td><select name="status">
                <?php if ($status) { ?>
                <option value="1" selected="selected"><?php echo $text_enabled; ?></option>
                <option value="0"><?php echo $text_disabled; ?></option>
                <?php } else { ?>
                <option value="1"><?php echo $text_enabled; ?></option>
                <option value="0" selected="selected"><?php echo $text_disabled; ?></option>
                <?php } ?>
              </select></td>
          </tr>
          <tr>
            <td><?php echo $entry_sort_order; ?></td>
            <td><input name="sort_order" value="<?php echo $sort_order; ?>" size="1" /></td>
          </tr>
        </table>
      </div>
    </form>
  </div>
</div>
</div>
<script type="text/javascript"><!--
function delete_file(download_extra_id){
	var file_name = $('#file_name').val();
	var cuccuc=confirm('Do you want delete file '+file_name);
	if(cuccuc){
		$.ajax({
			type:"GET",
			data:{file_name:file_name,download_extra_id:download_extra_id},
			url:"index.php?route=catalog/download_extra/deletefileDownloadExtra&token=<?php echo $token; ?>",
			success:function(){
				$('#txt_file_name').remove();
				<?php $file_name="";?>
				$('#file_name').remove();
				 html  = '<span id="txt_file_name"><?php echo $file_name; ?></span>';
				 html += '<input type="hidden" name="file_name" value="" id="file_name" />';
				 $('#download_file').after(html);
			},
			error:function (){
				alert('Error...');
			}
		});
	}
}
//--></script>
<script type="text/javascript" src="view/javascript/ckeditor/ckeditor.js"></script>
<script type="text/javascript"><!--
<?php foreach ($languages as $language) { ?>
CKEDITOR.replace('description<?php echo $language['language_id']; ?>', {
	filebrowserBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserImageBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserFlashBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserImageUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserFlashUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>'
});
<?php } ?>
//--></script>
<script type="text/javascript"><!--
function image_upload(field, thumb) {
	$('#dialog').remove();
	
	$('#content').prepend('<div id="dialog" style="padding: 3px 0px 0px 0px;"><iframe src="index.php?route=common/filemanager&token=<?php echo $token; ?>&field=' + encodeURIComponent(field) + '" style="padding:0; margin: 0; display: block; width: 100%; height: 100%;" frameborder="no" scrolling="auto"></iframe></div>');
	
	$('#dialog').dialog({
		title: '<?php echo $text_image_manager; ?>',
		close: function (event, ui) {
			if ($('#' + field).attr('value')) {
				$.ajax({
					url: 'index.php?route=common/filemanager/image&token=<?php echo $token; ?>&image=' + encodeURIComponent($('#' + field).attr('value')),
					dataType: 'text',
					success: function(text) {
						$('#' + thumb).replaceWith('<img src="' + text + '" alt="" id="' + thumb + '" />');
					}
				});
			}
		},	
		bgiframe: false,
		width: 800,
		height: 400,
		resizable: false,
		modal: false
	});
};
//--></script>
<script type="text/javascript" src="view/javascript/jquery/ajaxupload.js"></script>
<script type="text/javascript">
	$(function (){
		var interval;
		new AjaxUpload($('#download_file'),{
			action 		:'index.php?route=catalog/download_extra/upload&token=<?php echo $token; ?>',
			name		:'download_extra_file',
			autoSubmit	:true,
			responseType:'json',
			onSubmit  	:function (file, ext){
							$('#txt_upload').text('Uploading');
							this.disable();
							interval = window.setInterval(function (){
								if($('#txt_upload').text().length  <15 ){
									$('#txt_upload').text($('#txt_upload').text()+ '.');
								}else{
									$('#txt_upload').text('Uploading');
								}
							}, 200);
						},
			onComplete	:function (file, response){
						if(response.success){
							$('#txt_file_name').text(response.file_download_name);
							$('#file_name').val(response.file_download_name);
						}
						if(response.error){
							alert(response.error);
						}
						$('#txt_upload').text('Upload');
						window.clearInterval(interval);
						this.enable();
			}
			
		});
	});
</script>
<script type="text/javascript"><!--
$('#tabs a').tabs(); 
$('#languages a').tabs(); 
//--></script>
<?php echo $footer; ?>